﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SelfManagement.IServices;
using SelfManagement.Database.POCO;
using SelfManagement.Utility.Extensions;
using Ninject;

namespace SelfManagement.Services
{
    public class UserService: BaseService<User>, IUserService
    {
        [Inject]
        public IArticleCategoryService ArticleCategoryService { get; set; }
        /// <summary>
        /// 初始化用户数据
        /// </summary>
        /// <param name="user"></param>
        public void InitUserData(User user)
        {
            // 没有默认分类的文章，自动创建一个
            if(ArticleCategoryService.QueryUserArticleCategories(user.Id).Where(c => c.IsDefault).Count() == 0)
            {
                ArticleCategoryService.Insert(new ArticleCategory()
                {
                    User_Id = user.Id,
                    CategoryName = "默认分类",
                    IsDefault = true
                });
            }
        }

    }
}
